package com.niknik.deberc.core;

import com.niknik.woody.utils.cards.Card;

import java.util.*;

/**
 * User: yoda
 * Date: 15.02.11
 * Time: 17:56
 */
public class DebercHelper {
  public static final Random RANDOM = new Random();

  private static Card[] DEBERC_DECK;
  private static final HashMap<Card, Integer> points;

  static {
    DEBERC_DECK = new Card[32];
    System.arraycopy(Card.DECK, 5, DebercHelper.DEBERC_DECK, 0, 8);
    System.arraycopy(Card.DECK, 18, DebercHelper.DEBERC_DECK, 8, 8);
    System.arraycopy(Card.DECK, 31, DebercHelper.DEBERC_DECK, 16, 8);
    System.arraycopy(Card.DECK, 44, DebercHelper.DEBERC_DECK, 24, 8);
  }

  static {
    points = new HashMap<Card, Integer>();
    for (Card card : DEBERC_DECK) {
      switch (card.getVolume()) {
        case _7:
          points.put(card, 0);
          break;
        case _8:
          points.put(card, 0);
          break;
        case _9:
          points.put(card, 0);
          break;
        case _10:
          points.put(card, 10);
          break;
        case J:
          points.put(card, 2);
          break;
        case Q:
          points.put(card, 3);
          break;
        case K:
          points.put(card, 4);
          break;
        case A:
          points.put(card, 11);
          break;
      }
    }
  }

  public static List<Card> getShuffledDeck() {
    List<Card> result = new LinkedList<Card>();
    Collections.addAll(result, DEBERC_DECK);
    Collections.shuffle(result);
    return result;
  }

  public static int getCardPoints(Card card) {
    int value = points.get(card);
    return value;
  }
}
